package com.jvm.classloader;

/**
 * @author: csh
 * @Date: 2020/12/28 18:35
 * @Description:classLoader学习
 */
public class ClassLoaderTest {
    public static void main(String[] args) {
        //获取系统类加载器 sun.misc.Launcher$AppClassLoader@18b4aac2
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获取拓展类加载器 sun.misc.Launcher$ExtClassLoader@14ae5a5
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println(extClassLoader);

        //获取根类加载器 null
        ClassLoader bootstrapClassLoader = extClassLoader.getParent();
        System.out.println(bootstrapClassLoader);

        //用户自定类加载器  sun.misc.Launcher$AppClassLoader@18b4aac2(使用系统加载器进行加载)
        ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
        System.out.println(classLoader);
        //获取strng 类加载器 null(使用引导类加载器)java核心都是使用该种加载方式
        ClassLoader stringClassLoader = String.class.getClassLoader();
        System.out.println(stringClassLoader);
    }
}
